//
//  FallCollectionViewCell.swift
//  BusinessIOS
//
//  Created by Rain on 2018/11/6.
//  Copyright © 2018 XingJian Li. All rights reserved.
//

import UIKit


class FallCollectionViewCell: UICollectionViewCell {
    
    var titleLabel: UILabel!
    
    var timeLabel : UILabel!
    
    
    var imageview : UIImageView!
    
    var SeeLabel  : UILabel!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.titleLabel = UILabel()
        self.titleLabel.text = "保山市食品菌种和深加工基地建设项目"
        self.titleLabel.textAlignment = .left
        self.titleLabel.font = UIFont.systemFont(ofSize:14)//一般方法
        self.titleLabel.numberOfLines = 0
        self.titleLabel.backgroundColor = UIColor.groupTableViewBackground
        self.contentView.addSubview(self.titleLabel)
        
        
        
        self.timeLabel = UILabel()
        self.timeLabel.text = "2018-11-06"
        self.timeLabel.textAlignment = .left
        self.timeLabel.font = UIFont.systemFont(ofSize:14)//一般方法
        self.timeLabel.backgroundColor = UIColor.groupTableViewBackground
        self.contentView.addSubview(self.timeLabel)
        
        
        
        self.imageview = UIImageView()
       
        self.contentView.addSubview(self.imageview)
        
        self.SeeLabel = UILabel()
        self.SeeLabel.backgroundColor = UIColor.groupTableViewBackground
        self.SeeLabel.text = ">查看详情<"
        self.SeeLabel.font = UIFont.systemFont(ofSize:12)//一般方法
        self.SeeLabel.textAlignment = .center
        self.contentView.addSubview(self.SeeLabel)
        
        
        self.layoutView()
        
        
    }
    
    // 赋值方法 - 显示 cell 内容方法
    func pingtaiModelWithModel(model: ProjectModel) {
        
        self.titleLabel.text = model.title
        self.timeLabel.text  = model.createtime
         self.imageview.sd_setImage(with: NSURL.init(string: "http://wwwqjzsyzcscom.aykj.net.cn/api\(model.articlePic!)")! as URL, placeholderImage: UIImage.init(named: "app_hot_rec_1"), options: [], progress: nil, completed:nil)
        
        
        
        
    }
    
    func layoutView() {
        
        self.titleLabel.snp.makeConstraints { (make) in
            make.top.equalTo(self.snp.top).offset(0)
            make.left.equalTo(self.snp.left).offset(0)
            make.right.equalTo(self.snp.right).offset(0)
            make.height.equalTo(50)
        }
        
        self.timeLabel.snp.makeConstraints { (make) in
            make.top.equalTo(self.titleLabel.snp.bottom).offset(0)
            make.left.equalTo(self.snp.left).offset(0)
            make.right.equalTo(self.snp.right).offset(0)
            make.height.equalTo(20)
        }
        
        self.imageview.snp.makeConstraints { (make) in
            make.top.equalTo(self.timeLabel.snp.bottom).offset(0)
            make.left.equalTo(self.snp.left).offset(0)
            make.right.equalTo(self.snp.right).offset(0)
            make.height.equalTo(100)
        }
        
        self.SeeLabel.snp.makeConstraints { (make) in
            make.top.equalTo(self.imageview.snp.bottom).offset(0)
            make.left.equalTo(self.snp.left).offset(0)
            make.right.equalTo(self.snp.right).offset(0)
            make.height.equalTo(30)
        }
        
        
        
        
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
